package com.cqcj.login.service;

import com.cqcj.login.mapper.UserMapper;
import com.cqcj.login.pojo.User;
import com.cqcj.login.util.SqlSessionFactoryUtil;
import org.apache.ibatis.session.SqlSession;
import org.apache.ibatis.session.SqlSessionFactory;

public class LoginService {
    SqlSessionFactory sqlSessionFactory = SqlSessionFactoryUtil.getSqlSessionFactory();

    public User select(String username,String password){
        //通过mybatis配置文件连接数据库
        SqlSession sqlSession = sqlSessionFactory.openSession();
        UserMapper mapper = sqlSession.getMapper(UserMapper.class);
        //调用mapper在数据库中找有没有账号密码相同的用户
        User user =mapper.select(username,password);
        sqlSession.close();
        return user;
    }



}
